package com.cooba.content_frament;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.cooba.R;
import com.cooba.activitys.BookTicketsActivity;
import com.cooba.utils.ServerURL;

/**
 * Created by Administrator on 2015/12/7.
 * 发现
 */
public class FindFrament extends Fragment implements View.OnClickListener {

    private LinearLayout food;
    private LinearLayout film;
    private LinearLayout hotel;
    private LinearLayout KTV;
    private LinearLayout rental;
    private LinearLayout tourism;
    private LinearLayout bt_book;
    private LinearLayout let;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    private View contentview;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (contentview == null) {
            contentview = initview(inflater);
        }
        return contentview;
    }

    //初始化控件
    private View initview(LayoutInflater inflater) {
        View view = inflater.inflate(R.layout.find_frament, null, false);
        food = (LinearLayout) view.findViewById(R.id.food);
        film = (LinearLayout) view.findViewById(R.id.film);
        KTV = (LinearLayout) view.findViewById(R.id.KTV);
        hotel = (LinearLayout) view.findViewById(R.id.hotel);
        rental = (LinearLayout) view.findViewById(R.id.rental);
        tourism = (LinearLayout) view.findViewById(R.id.tourism);
        bt_book = (LinearLayout) view.findViewById(R.id.bt_book);
        let = (LinearLayout) view.findViewById(R.id.let);
        init();
        return view;
    }

    private void init() {
        food.setOnClickListener(this);
        film.setOnClickListener(this);
        KTV.setOnClickListener(this);
        rental.setOnClickListener(this);
        tourism.setOnClickListener(this);
        bt_book.setOnClickListener(this);
        let.setOnClickListener(this);
        hotel.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {
            case R.id.food:
                intent = new Intent(getActivity(), BookTicketsActivity.class);
                intent.putExtra("mMrl", ServerURL.美食);
                startActivity(intent);
                break;
            case R.id.film:
                intent = new Intent(getActivity(), BookTicketsActivity.class);
                intent.putExtra("mMrl", ServerURL.美食);
                startActivity(intent);
                break;
            case R.id.hotel:
                intent = new Intent(getActivity(), BookTicketsActivity.class);
                intent.putExtra("mMrl", ServerURL.酒店);
                startActivity(intent);
                break;
            case R.id.KTV:
                intent = new Intent(getActivity(), BookTicketsActivity.class);
                intent.putExtra("mMrl", ServerURL.美食);
                startActivity(intent);
                break;
            case R.id.rental:
                intent = new Intent(getActivity(), BookTicketsActivity.class);
                intent.putExtra("mMrl", ServerURL.美食);
                startActivity(intent);
                break;
            case R.id.tourism:
                intent = new Intent(getActivity(), BookTicketsActivity.class);
                intent.putExtra("mMrl", ServerURL.旅游);
                startActivity(intent);
                break;
            case R.id.bt_book:
                intent = new Intent(getActivity(), BookTicketsActivity.class);
                intent.putExtra("mMrl", ServerURL.汽车票);
                startActivity(intent);
                break;
            case R.id.let:
                intent = new Intent(getActivity(), BookTicketsActivity.class);
                intent.putExtra("mMrl", ServerURL.美食);
                startActivity(intent);
                break;
        }
    }
}
